package edu.maping.easy.composer;

import processing.xml.XMLElement;
import edu.maping.easy.sequence.ActionEventList;
import edu.maping.easy.sequence.ArrayListStepper;
import edu.maping.easy.sequence.Sequencer;
import edu.maping.easy.sequence.SequenceStep;

public class ComposeUnit {

	public ArrayListStepper<SequenceStep> sequence;

	public float start = 0;

	public float end = 0;

	public XMLElement xmlIzation() {
		XMLElement seqsElement = new XMLElement();
		seqsElement.setName("ComposeUnit");

		seqsElement.setAttribute("start", "" + start);
		seqsElement.setAttribute("end", "" + end);
		seqsElement.setAttribute("sequence", sequence.name);
		return seqsElement;
	}

	public void desXmlIzation(XMLElement seqsElement, Sequencer sequencer) {
		String startCad = seqsElement.getAttribute("start");
		String endCad = seqsElement.getAttribute("end");
		String seqName = seqsElement.getAttribute("sequence");

		start = Float.parseFloat(startCad);
		end = Float.parseFloat(endCad);

		sequence = sequencer.findSequenceByName(seqName);
		if(sequence == null){
			//CHuNGO
		}

	}
}
